package com.scott.crm.base.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author 黄后林 配置拦截规则 容器启动的时候就会执行addInterceptors方法加载规则
 * @version 1.0
 * @note
 * @date 2021-12-04 21:49:49
 */
@Configuration
public class LoginWebMvcConfiguration extends WebMvcConfigurationSupport {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        System.out.println("--------addInterceptors--------");
        registry.addInterceptor(loginInterceptor)
                //1、拦截所有请求
                .addPathPatterns("/**")
                //2、放过登陆页面   在login.html页面点击登陆按钮后发请求到 http://localhost:8080/login
                .excludePathPatterns("/login")
                //3、放过注销
                .excludePathPatterns("/logout")
                //4、放过注册
                .excludePathPatterns("/register");
    }
}
